import json

from apps.common.base.serializers import *
from apps.merchant.activity.models import *

class ActivityBaseSerializer(BaseSerializer):

    class Meta:
        model = Activity
        fields = "__all__"

class ActivityModelSerializer(BaseSerializer):

    activityParamsObj = serializers.SerializerMethodField()
    def get_activityParamsObj(self, obj):
        try:
            return json.loads(obj.activityParams)
        except:
            return {}

    class Meta:
        model = Activity
        fields = "__all__"